package co.baiku.boot.config;

import co.baiku.boot.common.tools.StringTools;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConditionalOnProperty("ajavaer.weixin.qy.app.corpid")
@ConfigurationProperties(prefix = "ajavaer.weixin.qy.app")
public class QyWeixinAppConfig {
    private String corpid;
    private String agentId;
    private String secret;
    private String userList;

    private String getTokenUrl = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={0}&corpsecret={1}";
    private String sendMsgUrl = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={0}";

    public String getSendMsgUrl() {
        return sendMsgUrl;
    }

    public String getUserList() {
        return userList;
    }

    public void setUserList(String userList) {
        this.userList = userList;
    }

    public String getCorpid() {
        return corpid;
    }

    public void setCorpid(String corpid) {
        this.corpid = corpid;
    }

    public String getAgentId() {
        return agentId;
    }

    public void setAgentId(String agentId) {
        this.agentId = agentId;
    }

    public String getSecret() {
        return secret;
    }

    public void setSecret(String secret) {
        this.secret = secret;
    }

    public String getGetTokenUrl() {
        return StringTools.format(getTokenUrl,corpid,secret);
    }

    public void setGetTokenUrl(String getTokenUrl) {
        this.getTokenUrl = getTokenUrl;
    }

    public String getSendMsgUrl(String accessToken) {
        return StringTools.format(sendMsgUrl,accessToken);
    }

    public void setSendMsgUrl(String sendMsgUrl) {
        this.sendMsgUrl = sendMsgUrl;
    }
}
